package com.agan.transaction.order.controller;


import com.agan.transaction.order.dto.OrderDTO;
import com.agan.transaction.order.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.UUID;
/**
 * @author 阿甘
 * @see https://study.163.com/course/courseMain.htm?courseId=1209367806&share=2&shareId=1016671292
 * @version 1.0
 * 注：如有任何疑问欢迎加入QQ群977438372 进行讨论
 */
@RestController
public class OrderController {
    @Autowired
    private OrderService orderService;

    @RequestMapping(value = "/t",method = RequestMethod.GET)
    public String test(@RequestParam("c") Integer c){
        System.out.println("---------------->"+c);

        OrderDTO obj=new OrderDTO();
        obj.setUserId(1);
        obj.setProductId(1);
        obj.setPaymentMoney(new BigDecimal(100));
        obj.setProductCount(1);
        //扣除2个积分
        obj.setDecreaseScore(2);
        //抵扣优惠卷
        obj.setCouponReceiveId(c);
        obj.setOrderNo(UUID.randomUUID().toString());
        this.orderService.createOrder(obj);

        return  "OK";
    }
}
